package com.woniuxy.service10aop;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 佘赛飞
 * @create 2021 -11 -07 11:14 AM
 */
//<bean id="student" class="类全限定名"/>
//默认的bean的id就是类名转成小驼峰
@Component("student")
public class Student {
    @Value("1")
    private int sid;
    @Value("zs")
    private String sname;

    //域属性：一个学生对应一个学校
    //按类型自动注入
  /*  @Autowired
    @Qualifier("school") //@Autowired+@Qualifier("school")按名称自动注入*/
   @Resource(name = "school")  //@Autowired+@Qualifier("school")按名称自动注入
                               //@Autowired+@Qualifier("school")按名称自动注入
    School school;

    public Student() {
    }

    public Student(int sid, String sname, School school) {
        this.sid = sid;
        this.sname = sname;
        this.school = school;
    }

    public int getSid() {
        return sid;
    }

    public void setSid(int sid) {
        this.sid = sid;
    }

    public String getSname() {
        return sname;
    }

    public void setSname(String sname) {
        this.sname = sname;
    }

    public School getSchool() {
        return school;
    }

    public void setSchool(School school) {
        this.school = school;
    }

    @Override
    public String toString() {
        return "Student{" +
                "sid=" + sid +
                ", sname='" + sname + '\'' +
                ", school=" + school +
                '}';
    }
}
